home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / filesy~1 / mfs610s.zoo / minixfs / trans.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-25  |  1.7 KB  |  81 lines

  1. /* This file is part of 'minixfs' Copyright 1991,1992,1993 S.N. Henson */
  2.  
  3. #include "minixfs.h"
  4. #include "proto.h"
  5. #include "global.h"
  6.  
  7. /* Decide whether to translate or not according to 'flag' this assumes 'flag'
  8.  * is the tos domain form and flag<<1 is the mint domain form. This code has
  9.  * been written so Domain() is called at most once .
  10.  */
  11.  
  12. int do_trans(flag,drive)
  13. long flag;
  14. int drive;
  15. {
  16.     long tmode,mmode;
  17.     tmode = fs_mode[drive] & flag ;
  18.     mmode = fs_mode[drive] & (flag<<1) ;
  19.  
  20.     /* If both modes , always translate */
  21.     if(mmode && tmode) return 1;
  22.     /* If neither , never */
  23.     if(!mmode && !tmode) return 0;
  24.     
  25.     if(mmode) 
  26.     {
  27.         if (Domain()==DOM_MINT) return 1;
  28.         else return 0;
  29.     }
  30.     if( tmode && (Domain()==DOM_TOS) ) return 1;
  31.     return 0;
  32. }
  33.  
  34.  
  35. /* I *HATE* this function , it attempts to turn a Minix filename into one
  36.   which wont cause TOS/DESKTOP etc to blow up , feel free to relace with
  37.   someting better (I doubt there could be much worse) if flag==0 just return
  38.   a null terminated version of 'name', mnamlength is the maximum filename length
  39.  */
  40.  
  41. char *tosify(name,flag,mnamlength)
  42. const char *name;
  43. int flag;
  44. int mnamlength;
  45. {
  46.     static char first[MNAME_MAX+8];
  47.     char *p,*ldt;
  48.     int i;
  49.  
  50.     if ((name[0] == '.' && name[1] == '\0')
  51.         || (name[0] == '.' && name[1] == '.' && name[2] == '\0'))
  52.       return (char *) name;
  53.  
  54.     strncpy (first, name, mnamlength);
  55.     first[mnamlength] = 0;
  56.  
  57.     if (!flag)
  58.       return first;
  59.  
  60.     ldt = strrchr (first, '.');
  61.     if (ldt == first)
  62.       ldt = NULL;
  63.     p = first;
  64.     for (i = 0; i < 8 && *p && p != ldt; i++, p++)
  65.       {
  66.         if (*p == '.')
  67.           *p = ',';
  68.         else
  69.           *p = toupper (*p);
  70.       }
  71.     if (ldt && ldt[1])
  72.       {
  73.         *p++ = '.';
  74.         ldt++;
  75.         for (i = 0; i < 3 && *ldt; i++)
  76.           *p++ = toupper (*ldt++);
  77.       }
  78.     *p = 0;
  79.     return first;
  80. }
  81.